﻿using System;
using System.Collections.Generic;
using System.Text;
using DevExpress.XtraLayout;
using DevExpress.XtraEditors;
using DevExpress.XtraTab;
using DevExpress.XtraBars.Docking2010.Views.Tabbed;
using DevExpress.XtraBars.Docking2010.Views;
using DevExpress.XtraBars.Ribbon;
using System.Windows.Forms;

namespace td.Core
{
    public class ViewContent : BaseForm, td.Core.IViewContent
    {
         private object caller;
        private AbstractViewContent Info;
        private XtraUserControl viewContentControl;

        public ViewContent(AbstractViewContent info, object caller)
        {
            this.Info = info;
            this.caller = caller;
            this.viewContentControl = info.ViewContentControl;
            if(this.viewContentControl !=null) this.viewContentControl.Dock = System.Windows.Forms.DockStyle.Fill;

            if (this.viewContentControl != null)
            {
                this.Controls.Add(this.viewContentControl);
            }

            this.Text = info.Title;
            this.title = info.Title;
            
        }


        public event EventHandler TitleChanged;


        private  string title = "未命名";
       
        /// <summary>
        /// base.Title
        /// </summary>
        string IViewContent.Title
        {
            get
            {
                return this.title;
            }
            set
            {
                if (!this.title.Equals(value))
                {
                    this.title = value;
                    this.Text = this.title;
                    if(this.TitleChanged!=null) this.TitleChanged(this, new EventArgs());
                }
            }
        }

       XtraUserControl IViewContent.ViewContentControl
        {
            get { return this.viewContentControl; }
        }
        void IDisposable.Dispose()
        {
            
        }

        private void InitializeComponent()
        {
            this.SuspendLayout();
            // 
            // ViewContent
            // 
            //this.AllowDisplayRibbon = false;
            //this.ClientSize = new System.Drawing.Size(284, 262);
            //this.Name = "ViewContent";
            //this.ResumeLayout(false);

        }
    }
}
